package janvee.com.example2;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

public class PrimitiveServlet implements Servlet {
    public void init(ServletConfig config) throws ServletException {
        System.out.println("init");
    }
    public void service(ServletRequest request, ServletResponse response)
            throws ServletException, IOException {
        System.out.println("from service");
        String data = "Hello. Roses are red.";
        PrintWriter out = response.getWriter();
        String responseHead = "HTTP/1.1\r\n" +
                "Content-Type: text/html\r\n" +
                "Content-Length: "+data.length()+"\r\n" +
                "\r\n";
        out.println("HTTP/1.1");
        out.println("Content-Type: text/html");
        out.println("Content-Length: "+data.length());
        out.println();

        out.println(data);
        System.err.println(123);
        out.println();
    }
    public void destroy() {
        System.out.println("destroy");
    }
    public String getServletInfo() {
        return null;
    }
    public ServletConfig getServletConfig() {
        return null;
    }
}

